package com.HuangJiaQing.www.controller;

import com.HuangJiaQing.www.model.Marketers;
import com.HuangJiaQing.www.model.User;
import com.HuangJiaQing.www.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.List;

/**
 * @author HONOR
 * @date 2022/7/29 15:11
 */
@Controller
public class UserController {
    @Autowired
    private UserService userService;

    @RequestMapping(value = "/toRegistUser", method = RequestMethod.GET)
    public String toRegisterUser() {
        return "registUser";
    }

    @RequestMapping(value = "/registUser", method = RequestMethod.POST)
    public String registerUser(User user) {
        boolean b = userService.registerUser(user);
        if (b) {
            return "login";
        } else {
            return "registUser";
        }
    }

    @RequestMapping("/userLogin")
    public String userLogin(Model model){
        List<Marketers> marketers = userService.userLogin();
        model.addAttribute("marketers",marketers);
        return "user";
    }



}
